/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.llollox.openharmonyprojects.compoundbuttongroupsample;

import com.llollox.openharmonyprojects.compoundbuttongroup.CompoundButtonGroup;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import org.junit.Before;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;

/**
 * Function description
 * class CompoundButtonGroupTest
 */
public class CompoundButtonGroupTest {
    private CompoundButtonGroup compoundButtonGroupTest;

    @Before
    public void getCompoundButtonGroupObject() {
        compoundButtonGroupTest = new CompoundButtonGroup(AbilityDelegatorRegistry.getAbilityDelegator().getAppContext());
    }

    /**
     * setCheckedPositions
     */
    @Test
    public void setCheckedPositionsTest() {
        String[] PLANETS = {"Mercury2", "Pluto3", "Saturn4", "Earth5",
                "Venus2", "Neptune3", "Uranus4", "Mars5", "Jupiter3", "Sun4"};
        compoundButtonGroupTest.setEntries(PLANETS);
        compoundButtonGroupTest.setNumCols(2);
        List<Integer> myList = new ArrayList<>();
        myList.add(1);
        myList.add(2);
        compoundButtonGroupTest.setCheckedPositions(myList);
        assertEquals(myList, compoundButtonGroupTest.getCheckedPositions());
    }

    /**
     * setNumCols
     */
    @Test
    public void setNumOfColsTest() {
        compoundButtonGroupTest.setNumCols(3);
        assertNotEquals(2, compoundButtonGroupTest.getNumCols());
    }

    /**
     * getLabelOrder
     */
    @Test
    public void setLabelOrderTest() {
        compoundButtonGroupTest.setLabelOrder(CompoundButtonGroup.LabelOrder.BEFORE);
        assertEquals(CompoundButtonGroup.LabelOrder.BEFORE, compoundButtonGroupTest.getLabelOrder());
    }

    /**
     * getCompoundType
     */
    @Test
    public void setCompoundType() {
        compoundButtonGroupTest.setCompoundType(CompoundButtonGroup.CompoundType.CHECK_BOX);
        assertEquals(CompoundButtonGroup.CompoundType.CHECK_BOX, compoundButtonGroupTest.getCompoundType());
    }
}
